package com.mrart.common.util;

import java.nio.ByteBuffer;
import java.util.UUID;

import org.apache.commons.codec.binary.Base64;

public class MissionIdUtils {

    public static String stringCreateMissionId(){
        return uuid();
    }
    
    public static String uuid() {
        UUID uuid = UUID.randomUUID();
        String s = uuidToBase64(uuid.toString());
        return "wd"+s;
    }
    
    private static String uuidToBase64(String str) {
        Base64 base64 = new Base64();
        UUID uuid = UUID.fromString(str);
        ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
        bb.putLong(uuid.getMostSignificantBits());
        bb.putLong(uuid.getLeastSignificantBits());
        return base64.encodeBase64URLSafeString(bb.array());
    }
    
    public static void main(String[] args) {
        System.out.println("uuid:"+uuid());
    }
}
